Skip to content

REF/CLN: Index.get_value wrapping incorrectly #31125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2020

Conversation

jbrockmendel
Copy link
Member

Index.get_value isn't wrapping non-scalar results correctly, as a result of which we have an ugly kludge in Series.__getitem__ to do that wrapping. This fixes that.

@@ -815,18 +815,6 @@ def __getitem__(self, key):
try:
result = self.index.get_value(self, key)

if not is_scalar(result):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just return directly here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah, we return result on the next line

@@ -4648,19 +4649,17 @@ def get_value(self, series, key):
return libindex.get_value_at(s, key)
except IndexError:
raise
except TypeError:
# generator/iterator-like
if is_iterator(key):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we just have no tests which hit this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be caught by the not is_scalar(key) check that we recently moved to the beginning of this method

@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Jan 18, 2020
@jreback jreback modified the milestones: 1.0.0, 1.1 Jan 18, 2020
@jreback jreback merged commit 52c22b2 into pandas-dev:master Jan 18, 2020
@jbrockmendel jbrockmendel deleted the bug-get_value2 branch January 18, 2020 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants